﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ITAP.Core.Modelling.Primitives;
using ITAP.ShprossesBuilder.Modelling.Components;

namespace ITAP.ShprossesBuilder.Operations
{
    public class OperationSelectShprossEnds : IOperation
    {
        private ShprossPoints endType;
        #region IOperation Members

        public string Name
        {
            get { return "Выделить один из концов профиля"; }
        }

        public OperationSelectShprossEnds(ShprossPoints endType)
        {
            this.endType = endType;
        }

        public OperationGroup OperationGroup
        {
            get { return OperationGroup.ShprossOperation; }
        }

        public System.Drawing.Image Thumbnail
        {
            get { return null; }
        }

        public void Execute(ModelControl modelControl)
        {
            foreach (IComponent selectedComponent in modelControl.ModelContainer.SelectedComponentsStack)
            {
                if (selectedComponent is Shpross)
                {
                    (selectedComponent as Shpross).Selected = true;
                    (selectedComponent as Shpross).SelectedPoint = endType;                    
                }
            }
        }

        public bool CanUndo
        {
            get { return false; }
        }

        #endregion
    }
}
